<SCRIPT LANGUAGE="JavaScript">  
    function change(temp)
    {
        $("#all").fadeOut("fast");
        $("#end").fadeOut("fast");
        $("#wait").fadeOut("fast");
        $("#post").fadeOut("fast");
        
        $("#"+temp.value).slideDown("slow");
    }
    
    function open_win(id)
    {
        window.open('../jobs/view/'+id,"_blank","toolbar=no, location=yes, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes, top=100, left=100, width=930, height=600");
    }    
    
</SCRIPT>

<?php
e($javascript->link('jquery.js')); 
echo "<div class='form'>";
    echo "<h2> My Jobs </h2>";
    echo "<hr color='#2A7EF7'>";

    echo $this->Element('myfunction');
    echo ":. Post a new Job ".$html->link('[ Here ]',array('controller'=>'jobs','action'=>'post'));
    echo "<br><br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp Category : ";
    echo "<select onchange='change(this)'><option>- Choose Category -</option><option value='all'> All </option><option value='post'> Posted </option><option value='end'> Expired </option><option value='wait'>Waiting</option></select>";
  
    
    echo "<div id='isi'></div>";

    echo "<div id='all' style='display:none'>";
    if(!empty($all))
    {    
        echo "<table class='jobs' cellpadding=0 cellspacing=0 style='margin-left:70px'>"; 
        echo "<tr><th width='100px'>Posted Date</th><th width='250px'>Position</th><th width='110px'>Career Level</th><th width='100px'>Year Exp</th><th width='120px'>Salary</th><th width='160px'>Status</th><th width='180px'>Action / Applicants</th></tr>";
        foreach($all as $data)
        {
            echo "<tr>";
                echo "<td>".mydate($data['Job']['created'])."</td>";                     
               // echo "<td>".$html->link($data['Job']['position'], array('controller' => 'jobs','action' => 'view','id' => $data['Job']['id']), array('class'=>'sky'))."</td>";

                echo "<td><a href='javascript:open_win(".$data['Job']['id'].")' class='sky'>".$data['Job']['position']."</a></td>"; 
                if($data['Job']['entry']==1)
                echo "<td>Entry Level</td>";
                if($data['Job']['middle']==1)
                echo "<td>Middle</td>";
                if($data['Job']['senior']==1)
                echo "<td>Senior</td>";
                if($data['Job']['top']==1)
                echo "<td>Top</td>";

                echo "<td>".$data['Job']['experience']."</td>";
                if($data['Job']['salary']==0)
                { echo "<td>".SALARY_0."</td>"; }
                if($data['Job']['salary']==1)
                { echo "<td>".SALARY_1."</td>"; }
                if($data['Job']['salary']==2)
                { echo "<td>".SALARY_2."</td>"; }
                if($data['Job']['salary']==3)
                { echo "<td>".SALARY_3."</td>"; }
                if($data['Job']['salary']==4)
                { echo "<td>".SALARY_4."</td>"; }     
                
                if($data['Job']['status']==0)
                {
                    if($data['Job']['slip']!='')
                    { echo "<td> Waiting Activation </td>"; }
                    else
                    { echo "<td> Waiting Payment </td>"; }
                    
                    echo "<td> ".$html->link('Edit',array('controller'=>'jobs','action'=>'edit','id'=>$data['Job']['id']) )." | ".$html->link('Payment',array('controller'=>'jobs','action'=>'payment','id'=>$data['Job']['id']) )." | ".$html->link('Cancel',array('controller'=>'jobs','action'=>'delete','id'=>$data['Job']['id']),array(),"Are you sure?" )." </td>"; 
                }
                else
                {
                    //$applicant = $this->requestAction(array('controller'=>'applicants','action'=>'new_applicant','id'=>$data['Job']['id']));
                    $applicant = $this->requestAction('applicants/new_applicant/'.$data['Job']['id']);
                    
                    if($data['Job']['end_date'] <= date("Y-m-d"))
                    { echo "<td> Expired </td>"; }
                    else
                    { echo "<td> Posted </td>"; }
        
                    echo "<td>".$html->link($applicant['total']." applicant(s)",array('controller'=>'applicants','action'=>'accept','id'=>$data['Job']['id'])); 
                    if($applicant['new'])
                    { echo " <font color='red'><sup><b>NEW</b></sup></font>"; }
                    if($data['Job']['end_date'] >= date("Y-m-d"))
                    { echo " | ".$html->link("Close",array('controller'=>'jobs','action'=>'close','id'=>$data['Job']['id'])); }
                    echo " </td>";
                   // echo $html->link($applicant['total'],array('controller'=>'applicants','action'=>'accept','id'=>$data['Job']['id']));
                    
                }
                        
            echo "</tr>"; 
            
       
        }
        echo "<tr class='end'><td class='end' colspan=7>&nbsp</td></tr>";
        echo "</table>";
    }
    else
    { echo "&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp <span class='red'>* There is no jobs in this category</span>"; }
    echo "</div>";

    echo "<div id='end' style='display:none'>";
    if(!empty($end))
    {    
        echo "<table class='jobs' cellpadding=0 cellspacing=0 style='margin-left:70px'>"; 
        echo "<tr><th width='100px'>Posted Date</th><th width='250px'>Position</th><th width='110px'>Career Level</th><th width='100px'>Year Exp</th><th width='120px'>Salary</th><th width='160px'>Status</th><th width='180px'>Action / Applicants</th></tr>";
        foreach($end as $data)
        {
            echo "<tr>";
                echo "<td>".mydate($data['Job']['created'])."</td>";                     
                echo "<td>".$html->link($data['Job']['position'], array('controller' => 'jobs','action' => 'view','id' => $data['Job']['id']), array('class'=>'sky'))."</td>";

                 
                if($data['Job']['entry']==1)
                echo "<td>Entry Level</td>";
                if($data['Job']['middle']==1)
                echo "<td>Middle</td>";
                if($data['Job']['senior']==1)
                echo "<td>senior</td>";
                if($data['Job']['top']==1)
                echo "<td>top</td>";

                echo "<td>".$data['Job']['experience']."</td>";
                if($data['Job']['salary']==0)
                { echo "<td>".SALARY_0."</td>"; }
                if($data['Job']['salary']==1)
                { echo "<td>".SALARY_1."</td>"; }
                if($data['Job']['salary']==2)
                { echo "<td>".SALARY_2."</td>"; }
                if($data['Job']['salary']==3)
                { echo "<td>".SALARY_3."</td>"; }
                if($data['Job']['salary']==4)
                { echo "<td>".SALARY_4."</td>"; }     
                
                if($data['Job']['status']==0)
                {
                    if($data['Job']['slip']!='')
                    { echo "<td> Waiting Activation </td>"; }
                    else
                    { echo "<td> Waiting Payment </td>"; }
                    
                    echo "<td> ".$html->link('Edit',array('controller'=>'jobs','action'=>'edit','id'=>$data['Job']['id']) )." | ".$html->link('Payment',array('controller'=>'jobs','action'=>'payment','id'=>$data['Job']['id']) )." | ".$html->link('Cancel',array('controller'=>'jobs','action'=>'delete','id'=>$data['Job']['id']),array(),"Are you sure?" )." </td>"; 
                }
                else
                {
                    //$applicant = $this->requestAction(array('controller'=>'applicants','action'=>'new_applicant','id'=>$data['Job']['id']));
                    $applicant = $this->requestAction('applicants/new_applicant/'.$data['Job']['id']);
                    
                    if($data['Job']['end_date'] < date("Y-m-d"))
                    { echo "<td> Expired </td>"; }
                    else
                    { echo "<td> Posted </td>"; }
        
                    echo "<td>".$html->link($applicant['total']." applicant(s)",array('controller'=>'applicants','action'=>'accept','id'=>$data['Job']['id'])); 
                    if($applicant['new'])
                    { echo " <font color='red'><sup><b>NEW</b></sup></font>"; }
                    if($data['Job']['end_date'] >= date("Y-m-d"))
                    { echo " | ".$html->link("Close",array('controller'=>'jobs','action'=>'close','id'=>$data['Job']['id'])); }
                    echo " </td>";
                   // echo $html->link($applicant['total'],array('controller'=>'applicants','action'=>'accept','id'=>$data['Job']['id']));
                    
                }
                        
            echo "</tr>"; 
            
       
        }
        echo "<tr class='end'><td class='end' colspan=7>&nbsp</td></tr>";
        echo "</table>";
    }
    else
    { echo "&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp <span class='red'>* There is no jobs in this category</span>"; }
    echo "</div>";
    
    echo "<div id='wait' style='display:none'>";
    if(!empty($wait))
    {    
        echo "<table class='jobs' cellpadding=0 cellspacing=0 style='margin-left:70px'>"; 
        echo "<tr><th width='100px'>Posted Date</th><th width='250px'>Position</th><th width='110px'>Career Level</th><th width='100px'>Year Exp</th><th width='120px'>Salary</th><th width='160px'>Status</th><th width='180px'>Action / Applicants</th></tr>";
        foreach($wait as $data)
        {
            echo "<tr>";
                echo "<td>".mydate($data['Job']['created'])."</td>";                     
                echo "<td>".$html->link($data['Job']['position'], array('controller' => 'jobs','action' => 'view','id' => $data['Job']['id']), array('class'=>'sky'))."</td>";

                 
                if($data['Job']['entry']==1)
                echo "<td>Entry Level</td>";
                if($data['Job']['middle']==1)
                echo "<td>Middle</td>";
                if($data['Job']['senior']==1)
                echo "<td>senior</td>";
                if($data['Job']['top']==1)
                echo "<td>top</td>";

                echo "<td>".$data['Job']['experience']."</td>";
                if($data['Job']['salary']==0)
                { echo "<td>".SALARY_0."</td>"; }
                if($data['Job']['salary']==1)
                { echo "<td>".SALARY_1."</td>"; }
                if($data['Job']['salary']==2)
                { echo "<td>".SALARY_2."</td>"; }
                if($data['Job']['salary']==3)
                { echo "<td>".SALARY_3."</td>"; }
                if($data['Job']['salary']==4)
                { echo "<td>".SALARY_4."</td>"; }     
                
                if($data['Job']['status']==0)
                {
                    if($data['Job']['slip']!='')
                    { echo "<td> Waiting Activation </td>"; }
                    else
                    { echo "<td> Waiting Payment </td>"; }
                    
                    echo "<td> ".$html->link('Edit',array('controller'=>'jobs','action'=>'edit','id'=>$data['Job']['id']) )." | ".$html->link('Payment',array('controller'=>'jobs','action'=>'payment','id'=>$data['Job']['id']) )." | ".$html->link('Cancel',array('controller'=>'jobs','action'=>'delete','id'=>$data['Job']['id']),array(),"Are you sure?" )." </td>"; 
                }
                else
                {
                    //$applicant = $this->requestAction(array('controller'=>'applicants','action'=>'new_applicant','id'=>$data['Job']['id']));
                    $applicant = $this->requestAction('applicants/new_applicant/'.$data['Job']['id']);
                    
                    if($data['Job']['end_date'] <= date("Y-m-d"))
                    { echo "<td> Expired </td>"; }
                    else
                    { echo "<td> Posted </td>"; }
        
                    echo "<td>".$html->link($applicant['total']." applicant(s)",array('controller'=>'applicants','action'=>'accept','id'=>$data['Job']['id'])); 
                    if($applicant['new'])
                    { echo " <font color='red'><sup><b>NEW</b></sup></font>"; }
                    if($data['Job']['end_date'] >= date("Y-m-d"))
                    { echo " | ".$html->link("Close",array('controller'=>'jobs','action'=>'close','id'=>$data['Job']['id'])); }
                    echo " </td>";
                   // echo $html->link($applicant['total'],array('controller'=>'applicants','action'=>'accept','id'=>$data['Job']['id']));
                    
                }
                        
            echo "</tr>"; 
            
       
        }
        echo "<tr class='end'><td class='end' colspan=7>&nbsp</td></tr>";
        echo "</table>";
    }
    else
    { echo "&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp <span class='red'>* There is no jobs in this category</span>"; }
    echo "</div>";
    
    echo "<div id='post' style='display:none'>";
    if(!empty($post))
    {    
        echo "<table class='jobs' cellpadding=0 cellspacing=0 style='margin-left:70px'>"; 
        echo "<tr><th width='100px'>Posted Date</th><th width='250px'>Position</th><th width='110px'>Career Level</th><th width='100px'>Year Exp</th><th width='120px'>Salary</th><th width='160px'>Status</th><th width='180px'>Action / Applicants</th></tr>";
        foreach($post as $data)
        {
            echo "<tr>";
                echo "<td>".mydate($data['Job']['created'])."</td>";                     
                echo "<td>".$html->link($data['Job']['position'], array('controller' => 'jobs','action' => 'view','id' => $data['Job']['id']), array('class'=>'sky'))."</td>";

                 
                if($data['Job']['entry']==1)
                echo "<td>Entry Level</td>";
                if($data['Job']['middle']==1)
                echo "<td>Middle</td>";
                if($data['Job']['senior']==1)
                echo "<td>senior</td>";
                if($data['Job']['top']==1)
                echo "<td>top</td>";

                echo "<td>".$data['Job']['experience']."</td>";
                if($data['Job']['salary']==0)
                { echo "<td>".SALARY_0."</td>"; }
                if($data['Job']['salary']==1)
                { echo "<td>".SALARY_1."</td>"; }
                if($data['Job']['salary']==2)
                { echo "<td>".SALARY_2."</td>"; }
                if($data['Job']['salary']==3)
                { echo "<td>".SALARY_3."</td>"; }
                if($data['Job']['salary']==4)
                { echo "<td>".SALARY_4."</td>"; }     
                
                if($data['Job']['status']==0)
                {
                    if($data['Job']['slip']!='')
                    { echo "<td> Waiting Activation </td>"; }
                    else
                    { echo "<td> Waiting Payment </td>"; }
                    
                    echo "<td> ".$html->link('Edit',array('controller'=>'jobs','action'=>'edit','id'=>$data['Job']['id']) )." | ".$html->link('Payment',array('controller'=>'jobs','action'=>'payment','id'=>$data['Job']['id']) )." | ".$html->link('Cancel',array('controller'=>'jobs','action'=>'delete','id'=>$data['Job']['id']),array(),"Are you sure?" )." </td>"; 
                }
                else
                {
                    //$applicant = $this->requestAction(array('controller'=>'applicants','action'=>'new_applicant','id'=>$data['Job']['id']));
                    $applicant = $this->requestAction('applicants/new_applicant/'.$data['Job']['id']);
                    
                    if($data['Job']['end_date'] <= date("Y-m-d"))
                    { echo "<td> Expired </td>"; }
                    else
                    { echo "<td> Posted </td>"; }
        
                    echo "<td>".$html->link($applicant['total']." applicant(s)",array('controller'=>'applicants','action'=>'accept','id'=>$data['Job']['id'])); 
                    if($applicant['new'])
                    { echo " <font color='red'><sup><b>NEW</b></sup></font>"; }
                    if($data['Job']['end_date'] >= date("Y-m-d"))
                    { echo " | ".$html->link("Close",array('controller'=>'jobs','action'=>'close','id'=>$data['Job']['id'])); }
                    echo " </td>";
                   // echo $html->link($applicant['total'],array('controller'=>'applicants','action'=>'accept','id'=>$data['Job']['id']));
                    
                }
                        
            echo "</tr>"; 
            
       
        }
        echo "<tr class='end'><td class='end' colspan=7>&nbsp</td></tr>";
        echo "</table>";
    }
    else
    { echo "&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp <span class='red'>* There is no jobs in this category</span>"; }
    echo "</div>";

    
echo "</div>"; 


                                                    
?>